<template>
  <div class="app-container">

    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="4位年份+2位月份+4位流水，对应SYS_USER表中的USERNAME" prop="userid">
        <el-input v-model="queryParams.userid" placeholder="请输入4位年份+2位月份+4位流水，对应SYS_USER表中的USERNAME" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="责任人" prop="username">
        <el-input v-model="queryParams.username" placeholder="请输入责任人" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="污染地块编码" prop="wrdkbm">
        <el-input v-model="queryParams.wrdkbm" placeholder="请输入污染地块编码" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="污染地块名称" prop="wrdkmc">
        <el-input v-model="queryParams.wrdkmc" placeholder="请输入污染地块名称" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="省名称" prop="smc">
        <el-input v-model="queryParams.smc" placeholder="请输入省名称" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="省编码" prop="sfbm">
        <el-input v-model="queryParams.sfbm" placeholder="请输入省编码" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="地市名称" prop="dsmc">
        <el-input v-model="queryParams.dsmc" placeholder="请输入地市名称" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="地市编码" prop="dsbm">
        <el-input v-model="queryParams.dsbm" placeholder="请输入地市编码" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="区县名称" prop="qxmc">
        <el-input v-model="queryParams.qxmc" placeholder="请输入区县名称" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="区县编码" prop="qxbm">
        <el-input v-model="queryParams.qxbm" placeholder="请输入区县编码" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="地块范围，地块地址描述" prop="wrdkbounds">
        <el-input v-model="queryParams.wrdkbounds" placeholder="请输入地块范围，地块地址描述" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="坐标系统，CGCS2000" prop="zbxt">
        <el-input v-model="queryParams.zbxt" placeholder="请输入坐标系统，CGCS2000" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="中心点经度，以度为单位，保留5位" prop="zxjd">
        <el-input v-model="queryParams.zxjd" placeholder="请输入中心点经度，以度为单位，保留5位" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="中心点纬度，以度为单位，保留5位" prop="zxwd">
        <el-input v-model="queryParams.zxwd" placeholder="请输入中心点纬度，以度为单位，保留5位" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="污染地块位置" prop="wrdkwz">
        <el-input v-model="queryParams.wrdkwz" placeholder="请输入污染地块位置" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="污染地块占地面积，m2，保留两位" prop="wrdkarea">
        <el-input v-model="queryParams.wrdkarea" placeholder="请输入污染地块占地面积，m2，保留两位" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="污染地块状态,参考DM_WRDKZT" prop="dkzt">
        <el-input v-model="queryParams.dkzt" placeholder="请输入污染地块状态,参考DM_WRDKZT" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="污染地块界址点坐标X,Y,参考wrdk_grid，CLASS_ID=1" prop="wrdkzbxy">
        <el-input v-model="queryParams.wrdkzbxy" placeholder="请输入污染地块界址点坐标X,Y,参考wrdk_grid，CLASS_ID=1" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="污染土壤信息平台备案时间" prop="recordtime">
        <el-date-picker v-model="queryParams.recordtime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
                        range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
      </el-form-item>
      <el-form-item label="年度" prop="curyear">
        <el-input v-model="queryParams.curyear" placeholder="请输入年度" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="控制地块目录审批流程状态，0=未审批，1=审批通过，2=审批驳回" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择控制地块目录审批流程状态，0=未审批，1=审批通过，2=审批驳回" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="重点区域ID，DM_ZDQYMC-ID" prop="qyid">
        <el-input v-model="queryParams.qyid" placeholder="请输入重点区域ID，DM_ZDQYMC-ID" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="备注" prop="note">
        <el-input v-model="queryParams.note" placeholder="请输入备注" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="符合规划用地要求的再开发利用污染地块的面积，m2，保留两位" prop="reusearea">
        <el-input v-model="queryParams.reusearea" placeholder="请输入符合规划用地要求的再开发利用污染地块的面积，m2，保留两位" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="再开发利用区域符合土壤环境质量要求的界址点坐标X，Y, 参考CMS_GRID，CLASS_ID=2" prop="jzdzb">
        <el-input v-model="queryParams.jzdzb" placeholder="请输入再开发利用区域符合土壤环境质量要求的界址点坐标X，Y, 参考CMS_GRID，CLASS_ID=2" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="控制污染地块保存状态，0：保存未提交可修改（驳回），1：提交不可修改" prop="saveflag">
        <el-input v-model="queryParams.saveflag" placeholder="请输入控制污染地块保存状态，0：保存未提交可修改（驳回），1：提交不可修改" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="控制地块符合利用保存状态，0：保存未提交可修改（驳回），1：提交不可修改" prop="savesign">
        <el-input v-model="queryParams.savesign" placeholder="请输入控制地块符合利用保存状态，0：保存未提交可修改（驳回），1：提交不可修改" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="控制符合再利用审批流程状态，0=未审批，1=审批通过，2=审批驳回" prop="state">
        <el-input v-model="queryParams.state" placeholder="请输入控制符合再利用审批流程状态，0=未审批，1=审批通过，2=审批驳回" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="创建时间" prop="createTime">
        <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
                        range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                   v-hasPermi="['wrdk:wrdkland:create']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
                   v-hasPermi="['wrdk:wrdkland:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
      <el-table-column label="污染地块ID" align="center" prop="id" />
      <el-table-column label="4位年份+2位月份+4位流水，对应SYS_USER表中的USERNAME" align="center" prop="userid" />
      <el-table-column label="责任人" align="center" prop="username" />
      <el-table-column label="污染地块编码" align="center" prop="wrdkbm" />
      <el-table-column label="污染地块名称" align="center" prop="wrdkmc" />
      <el-table-column label="省名称" align="center" prop="smc" />
      <el-table-column label="省编码" align="center" prop="sfbm" />
      <el-table-column label="地市名称" align="center" prop="dsmc" />
      <el-table-column label="地市编码" align="center" prop="dsbm" />
      <el-table-column label="区县名称" align="center" prop="qxmc" />
      <el-table-column label="区县编码" align="center" prop="qxbm" />
      <el-table-column label="地块范围，地块地址描述" align="center" prop="wrdkbounds" />
      <el-table-column label="坐标系统，CGCS2000" align="center" prop="zbxt" />
      <el-table-column label="中心点经度，以度为单位，保留5位" align="center" prop="zxjd" />
      <el-table-column label="中心点纬度，以度为单位，保留5位" align="center" prop="zxwd" />
      <el-table-column label="污染地块位置" align="center" prop="wrdkwz" />
      <el-table-column label="污染地块占地面积，m2，保留两位" align="center" prop="wrdkarea" />
      <el-table-column label="污染地块状态,参考DM_WRDKZT" align="center" prop="dkzt" />
      <el-table-column label="污染地块界址点坐标X,Y,参考wrdk_grid，CLASS_ID=1" align="center" prop="wrdkzbxy" />
      <el-table-column label="污染土壤信息平台备案时间" align="center" prop="recordtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.recordtime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="年度" align="center" prop="curyear" />
      <el-table-column label="控制地块目录审批流程状态，0=未审批，1=审批通过，2=审批驳回" align="center" prop="status" />
      <el-table-column label="重点区域ID，DM_ZDQYMC-ID" align="center" prop="qyid" />
      <el-table-column label="备注" align="center" prop="note" />
      <el-table-column label="符合规划用地要求的再开发利用污染地块的面积，m2，保留两位" align="center" prop="reusearea" />
      <el-table-column label="再开发利用区域符合土壤环境质量要求的界址点坐标X，Y, 参考CMS_GRID，CLASS_ID=2" align="center" prop="jzdzb" />
      <el-table-column label="控制污染地块保存状态，0：保存未提交可修改（驳回），1：提交不可修改" align="center" prop="saveflag" />
      <el-table-column label="控制地块符合利用保存状态，0：保存未提交可修改（驳回），1：提交不可修改" align="center" prop="savesign" />
      <el-table-column label="控制符合再利用审批流程状态，0=未审批，1=审批通过，2=审批驳回" align="center" prop="state" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                     v-hasPermi="['wrdk:wrdkland:update']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                     v-hasPermi="['wrdk:wrdkland:delete']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

    <!-- 对话框(添加 / 修改) -->
    <el-dialog :title="title" :visible.sync="open" width="500px" v-dialogDrag append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="4位年份+2位月份+4位流水，对应SYS_USER表中的USERNAME" prop="userid">
          <el-input v-model="form.userid" placeholder="请输入4位年份+2位月份+4位流水，对应SYS_USER表中的USERNAME" />
        </el-form-item>
        <el-form-item label="责任人" prop="username">
          <el-input v-model="form.username" placeholder="请输入责任人" />
        </el-form-item>
        <el-form-item label="污染地块编码" prop="wrdkbm">
          <el-input v-model="form.wrdkbm" placeholder="请输入污染地块编码" />
        </el-form-item>
        <el-form-item label="污染地块名称" prop="wrdkmc">
          <el-input v-model="form.wrdkmc" placeholder="请输入污染地块名称" />
        </el-form-item>
        <el-form-item label="省名称" prop="smc">
          <el-input v-model="form.smc" placeholder="请输入省名称" />
        </el-form-item>
        <el-form-item label="省编码" prop="sfbm">
          <el-input v-model="form.sfbm" placeholder="请输入省编码" />
        </el-form-item>
        <el-form-item label="地市名称" prop="dsmc">
          <el-input v-model="form.dsmc" placeholder="请输入地市名称" />
        </el-form-item>
        <el-form-item label="地市编码" prop="dsbm">
          <el-input v-model="form.dsbm" placeholder="请输入地市编码" />
        </el-form-item>
        <el-form-item label="区县名称" prop="qxmc">
          <el-input v-model="form.qxmc" placeholder="请输入区县名称" />
        </el-form-item>
        <el-form-item label="区县编码" prop="qxbm">
          <el-input v-model="form.qxbm" placeholder="请输入区县编码" />
        </el-form-item>
        <el-form-item label="地块范围，地块地址描述" prop="wrdkbounds">
          <el-input v-model="form.wrdkbounds" placeholder="请输入地块范围，地块地址描述" />
        </el-form-item>
        <el-form-item label="坐标系统，CGCS2000" prop="zbxt">
          <el-input v-model="form.zbxt" placeholder="请输入坐标系统，CGCS2000" />
        </el-form-item>
        <el-form-item label="中心点经度，以度为单位，保留5位" prop="zxjd">
          <el-input v-model="form.zxjd" placeholder="请输入中心点经度，以度为单位，保留5位" />
        </el-form-item>
        <el-form-item label="中心点纬度，以度为单位，保留5位" prop="zxwd">
          <el-input v-model="form.zxwd" placeholder="请输入中心点纬度，以度为单位，保留5位" />
        </el-form-item>
        <el-form-item label="污染地块位置" prop="wrdkwz">
          <el-input v-model="form.wrdkwz" placeholder="请输入污染地块位置" />
        </el-form-item>
        <el-form-item label="污染地块占地面积，m2，保留两位" prop="wrdkarea">
          <el-input v-model="form.wrdkarea" placeholder="请输入污染地块占地面积，m2，保留两位" />
        </el-form-item>
        <el-form-item label="污染地块状态,参考DM_WRDKZT" prop="dkzt">
          <el-input v-model="form.dkzt" placeholder="请输入污染地块状态,参考DM_WRDKZT" />
        </el-form-item>
        <el-form-item label="污染地块界址点坐标X,Y,参考wrdk_grid，CLASS_ID=1" prop="wrdkzbxy">
          <el-input v-model="form.wrdkzbxy" placeholder="请输入污染地块界址点坐标X,Y,参考wrdk_grid，CLASS_ID=1" />
        </el-form-item>
        <el-form-item label="污染土壤信息平台备案时间" prop="recordtime">
          <el-date-picker clearable v-model="form.recordtime" type="date" value-format="timestamp" placeholder="选择污染土壤信息平台备案时间" />
        </el-form-item>
        <el-form-item label="年度" prop="curyear">
          <el-input v-model="form.curyear" placeholder="请输入年度" />
        </el-form-item>
        <el-form-item label="控制地块目录审批流程状态，0=未审批，1=审批通过，2=审批驳回" prop="status">
          <el-radio-group v-model="form.status">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="重点区域ID，DM_ZDQYMC-ID" prop="qyid">
          <el-input v-model="form.qyid" placeholder="请输入重点区域ID，DM_ZDQYMC-ID" />
        </el-form-item>
        <el-form-item label="备注" prop="note">
          <el-input v-model="form.note" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="符合规划用地要求的再开发利用污染地块的面积，m2，保留两位" prop="reusearea">
          <el-input v-model="form.reusearea" placeholder="请输入符合规划用地要求的再开发利用污染地块的面积，m2，保留两位" />
        </el-form-item>
        <el-form-item label="再开发利用区域符合土壤环境质量要求的界址点坐标X，Y, 参考CMS_GRID，CLASS_ID=2" prop="jzdzb">
          <el-input v-model="form.jzdzb" placeholder="请输入再开发利用区域符合土壤环境质量要求的界址点坐标X，Y, 参考CMS_GRID，CLASS_ID=2" />
        </el-form-item>
        <el-form-item label="控制污染地块保存状态，0：保存未提交可修改（驳回），1：提交不可修改" prop="saveflag">
          <el-input v-model="form.saveflag" placeholder="请输入控制污染地块保存状态，0：保存未提交可修改（驳回），1：提交不可修改" />
        </el-form-item>
        <el-form-item label="控制地块符合利用保存状态，0：保存未提交可修改（驳回），1：提交不可修改" prop="savesign">
          <el-input v-model="form.savesign" placeholder="请输入控制地块符合利用保存状态，0：保存未提交可修改（驳回），1：提交不可修改" />
        </el-form-item>
        <el-form-item label="控制符合再利用审批流程状态，0=未审批，1=审批通过，2=审批驳回" prop="state">
          <el-input v-model="form.state" placeholder="请输入控制符合再利用审批流程状态，0=未审批，1=审批通过，2=审批驳回" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { createwrdkland, updatewrdkland, deletewrdkland, getwrdkland, getwrdklandPage, exportwrdklandExcel } from "@/api/wrdk/wrdkland";

export default {
  name: "wrdkland",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 污染地块安全利用率调查列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        userid: null,
        username: null,
        wrdkbm: null,
        wrdkmc: null,
        smc: null,
        sfbm: null,
        dsmc: null,
        dsbm: null,
        qxmc: null,
        qxbm: null,
        wrdkbounds: null,
        zbxt: null,
        zxjd: null,
        zxwd: null,
        wrdkwz: null,
        wrdkarea: null,
        dkzt: null,
        wrdkzbxy: null,
        recordtime: [],
        curyear: null,
        status: null,
        qyid: null,
        note: null,
        reusearea: null,
        jzdzb: null,
        saveflag: null,
        savesign: null,
        state: null,
        createTime: [],
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 执行查询
      getwrdklandPage(this.queryParams).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        userid: undefined,
        username: undefined,
        wrdkbm: undefined,
        wrdkmc: undefined,
        smc: undefined,
        sfbm: undefined,
        dsmc: undefined,
        dsbm: undefined,
        qxmc: undefined,
        qxbm: undefined,
        wrdkbounds: undefined,
        zbxt: undefined,
        zxjd: undefined,
        zxwd: undefined,
        wrdkwz: undefined,
        wrdkarea: undefined,
        dkzt: undefined,
        wrdkzbxy: undefined,
        recordtime: undefined,
        curyear: undefined,
        status: undefined,
        qyid: undefined,
        note: undefined,
        reusearea: undefined,
        jzdzb: undefined,
        saveflag: undefined,
        savesign: undefined,
        state: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加污染地块安全利用率调查";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id;
      getwrdkland(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改污染地块安全利用率调查";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          return;
        }
        // 修改的提交
        if (this.form.id != null) {
          updatewrdkland(this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
        createwrdkland(this.form).then(response => {
          this.$modal.msgSuccess("新增成功");
          this.open = false;
          this.getList();
        });
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
      this.$modal.confirm('是否确认删除污染地块安全利用率调查编号为"' + id + '"的数据项?').then(function() {
          return deletewrdkland(id);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams};
      params.pageNo = undefined;
      params.pageSize = undefined;
      this.$modal.confirm('是否确认导出所有污染地块安全利用率调查数据项?').then(() => {
          this.exportLoading = true;
          return exportwrdklandExcel(params);
        }).then(response => {
          this.$download.excel(response, '污染地块安全利用率调查.xls');
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>
